package com.ikingtech.platform.service.application.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ikingtech.platform.service.application.entity.ApplicationModelRelationDO;
import com.ikingtech.platform.service.application.mapper.ApplicationModelRelationMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author tie yan
 */
@Service
@RequiredArgsConstructor
public class ApplicationModelRelationService extends ServiceImpl<ApplicationModelRelationMapper, ApplicationModelRelationDO> {

    public void removeByMasterModelId(String masterModelId) {
        this.remove(Wrappers.<ApplicationModelRelationDO>lambdaQuery().eq(ApplicationModelRelationDO::getMasterModelId, masterModelId));
    }

    public void removeByModelId(String modelId) {
        this.remove(Wrappers.<ApplicationModelRelationDO>lambdaQuery().eq(ApplicationModelRelationDO::getModelId, modelId));
    }

    public List<ApplicationModelRelationDO> listByMasterModelIds(List<String> masterModelIds) {
        return this.list(Wrappers.<ApplicationModelRelationDO>lambdaQuery().in(ApplicationModelRelationDO::getMasterModelId, masterModelIds));
    }

    public List<ApplicationModelRelationDO> listByMasterModelId(String masterModelId) {
        return this.list(Wrappers.<ApplicationModelRelationDO>lambdaQuery().eq(ApplicationModelRelationDO::getMasterModelId, masterModelId));
    }
}
